//
//  BaseTabBarController.m
//  LOL视频播放
//
//  Created by 花花蔡 on 2016/12/5.
//  Copyright © 2016年 com.HuaHuaCai. All rights reserved.
//

#import "BaseTabBarController.h"
#import "Public.h"
#import "RecommendController.h"
#import "BaseNavigationController.h"
#import "MineTableViewController.h"
#import "LiveViewController.h"
#import "HeroTableViewController.h"
@interface BaseTabBarController ()

@end

@implementation BaseTabBarController

//单例
+(BaseTabBarController *)sharedBaseTabBarController{
    
    static BaseTabBarController *baseTVC = nil;
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        
        baseTVC = [[BaseTabBarController alloc]init];
        
        //字体颜色
        baseTVC.tabBar.tintColor = TabBar_T_Color;
    });
    
    return baseTVC;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //加载四个页面
    [self setupChildViewControllers];
    
}

- (void)setupChildViewControllers {
    
    //数组放四个界面
    NSMutableArray *childArray = [[NSMutableArray alloc]initWithCapacity:4];
    
    /*
     *  1. 推荐
     */
    RecommendController *recommendVC = [[RecommendController alloc]init];
    [recommendVC.tabBarItem setTitle:@"推荐"];
    [recommendVC.tabBarItem setImage:[UIImage imageNamed:@"btn_home_normal"]];
    [recommendVC.tabBarItem setSelectedImage:[UIImage imageNamed:@"btn_home_selected"]];
    
    BaseNavigationController *naviRecommendNVC = [[BaseNavigationController alloc] initWithRootViewController:recommendVC];
    //添加到子视图数组中
    [childArray addObject:naviRecommendNVC];
    
    /*
     * 2.英雄
     */
    HeroTableViewController *heroVC = [[HeroTableViewController alloc] init];
    [heroVC.tabBarItem setTitle:@"英雄"];
    [heroVC.tabBarItem setImage:[UIImage imageNamed:@"btn_hero_normal"]];
    [heroVC.tabBarItem setSelectedImage:[UIImage imageNamed:@"btn_hero_selected"]];
    
    BaseNavigationController *heroNVC = [[BaseNavigationController alloc] initWithRootViewController:heroVC];
    [childArray addObject:heroNVC];
    
    /*
     * 3.直播
     */
    LiveViewController *liveVC = [[LiveViewController alloc] init];
    [liveVC.tabBarItem setTitle:@"直播"];
    [liveVC.tabBarItem setImage:[UIImage imageNamed:@"btn_live_normal"]];
    [liveVC.tabBarItem setSelectedImage:[UIImage imageNamed:@""]];
    
    BaseNavigationController *liveNVC = [[BaseNavigationController alloc] initWithRootViewController:liveVC];
    [childArray addObject:liveNVC];
    /*
     * 4.我的界面
     */
    MineTableViewController *mineTVC = [[MineTableViewController alloc] initWithStyle:UITableViewStyleGrouped];
    
    [mineTVC.tabBarItem setTitle:@"我的"];
    [mineTVC.tabBarItem setImage:[UIImage imageNamed:@"btn_user_normal"]];
    [mineTVC.tabBarItem setSelectedImage:[UIImage imageNamed:@"btn_user_selected@2x"]];
    BaseNavigationController *mineNVC = [[BaseNavigationController alloc] initWithRootViewController:mineTVC];
    
    [childArray addObject:mineNVC];
    
    //给tabBarController 设置子视图
    [self setViewControllers:childArray animated:YES];
    
}


@end
